//自定义异常
public class LoginIn {
    private String userName="admin";
    private String password="123456";
public void LoginInfo(String userName,String  password)throws UserNameException,PasswordException{
        if(!this.userName.equals(userName)){

throw new UserNameException("用户名错误");
        }
        if(!this.password.equals(password)){
throw new PasswordException("密码有误");
        }
    System.out.println("登陆成功");
}

    public static void main(String[] args) {
        LoginIn loginIn=new LoginIn();
        try {
            loginIn.LoginInfo("Admin","123456");
        }catch (UserNameException e){
            e.printStackTrace();
            System.out.println("UserNameException");
        }catch (PasswordException e){
            e.printStackTrace();
            System.out.println("PasswordException");
        }

    }
}
